

var deviceId;
var deviceName;



var device_obj = null;
var m_Application = null;
var netManager_obj  = null;
window.onWAEReady = function(){
	device_obj = wae.create("Devices");
	m_Application = wae.create("Application");
	showPage();
	setTimeout(function(){document.getElementById("changeId").focus();},500)
	
}

function  showPage(){
	showVer();
	showMacId();
	showDeviceName();
	
}



function $(str) { return document.getElementById(str)}


function getDeviceid(){
	deviceId = device_obj.getTvataDeviceID();
}

function showDeviceid(){
	
}


function getDeviceName(){
	deviceName = device_obj.getTvataDeviceName();
}

function showDeviceName(){
	getDeviceName();
	$("deviceeNameId").innerHTML=deviceName;
}

function showVer(){
	
	var _android_version = m_Application.versionName();
	//var _version = "V "+_android_version+"."+ HTML_PAGE_VERSION;
	var _version = "V "+_android_version+"."+ getVersion();
	$("versionName").innerHTML = _version ;
	

}

function showMacId(){
	try{
	if(!netManager_obj){
		netManager_obj = wae.create("Net.NetworkManager")
	}
	
	var netManager = netManager_obj.getNetInfo();
	var net_mac = netManager.match(/MAC:[\s\S]*?,/)[0].replace(/MAC:|,/g,'').replace(/:/g,'');
	$("macId").style.display="block";
	$("macId").innerHTML = '设备ID：<span>'+net_mac+'</span>'
		
	
	}catch(e){alert(e.message)}
}




function getVersion(){
	try{
		
		var simpleFile_obj = null;
		simpleFile_obj = wae.create("DATA.SimpleFile");
		var  ver_str = simpleFile_obj.readFromRootPath('version.txt');
		if(!ver_str||ver_str==null||ver_str.length!=5){
			ver_str = "00000";	
		}
		/*var ver_obj = ver_str.split("");
		var ver_name = "set";
		var ver_version = "1";
		var ver_index = "";
		switch(ver_name){
			case "launcher":ver_index= 0;break;
			case "portal":ver_index= 1;break;
			case "edu":ver_index= 2;break;
			case "live":ver_index= 3;break;
			case "set":ver_index= 4;break;
		}
		ver_obj.splice(ver_index,1,ver_version);
		var new_version = (ver_obj.toString()).replace(/\,/g,"");
		simpleFile_obj.writeToRootPath("version.txt", new_version, true);*/
		return ver_str;
	}catch(e){
		return "00000";	
	}	
}

function DeviceRename(){
	var sear_stt = prompt("请输入设备名称:");
	if(sear_stt){
		device_obj.saveTvataDeviceName(sear_stt);
		showDeviceName();
	}	
}






